<?php	

class posts extends Controller
{
	
	public function index()
	{	
		$this->session();
		$model = new forum();
		$date = gmdate ( 'YmdHis' );
		$post = $model->insertPost($_POST['threadId'],$_SESSION['stud_no'], $date, $_POST['message'] ); 
		$message = 'Your message has been posted.
		Click <a href="/members/orgs/' . $_SESSION['orgname'] . '/threads/' . $_POST['threadId'] . '">here</a> to go back.' ;
		new View('emptyTemplate', 
		array( 'message' => $message )) ;	
	}

	public function edit()
	{	
		$this->session();
		$data['title'] = new BufferedView('orgPage/titles/torgSitePost');
		$data['content'] = new BufferedView('orgPage/orgSiteEditPost',array(
		"message" => $_POST['message'],
		"postId" => $_POST['postId'],
		"threadId" => $_POST['threadId']
		) );
			new View ("orgPage/orgSiteTemplate", $data);
	}

	public function update()
	{	
		$this->session();
		$model = new forum();
		$post = $model->updatePost($_POST['message'],$_POST['postId'] ); 
		$message = 'Your post has been updated.
		Click <a href="/members/orgs/' . $_SESSION['orgname'] . '/threads/' . $_POST['threadId'] . '">here</a> to go back.' ;
		new View('emptyTemplate', 
		array( 'message' => $message )) ;	
	}


}

